<template>
    <tr>
        <td v-show="!is_edit">{{classRoom.classId}}</td>
        <td v-show="!is_edit">{{classRoom.className}}</td>
        <td v-show="!is_edit">{{classRoom.classStudentCount}}</td>
        <td v-show="!is_edit">{{classRoom.classDescription}}</td>
        <td v-show="!is_edit">
            <!--modify点击修改，变为框-->
            <el-button type="primary" icon="el-icon-edit" @click="modify">修改</el-button>
        </td>
        <td v-show="!is_edit">
            <el-button type="primary" icon="el-icon-delete" @click="deleteClass">删除</el-button>
        </td>
        <el-dialog
            title="添加班级信息"
            :visible.sync="centerDialogVisible"
            width="30%"
            center>
            <el-button @click="centerDialogVisible = false">取 消</el-button>
        </el-dialog>
        <td v-show="is_edit"><input class="w-50" type="text" v-model.number="classRoom.classId"></td>
        <td v-show="is_edit"><input class="w-50" type="text" v-model="classRoom.className"></td>
        <td v-show="is_edit"><input class="w-50" type="text" v-model.number="classRoom.classStudentCount"></td>
        <td v-show="is_edit"><input class="w-50" type="text" v-model="classRoom.classDescription"></td>
        <td v-show="is_edit">
            <el-button type="primary" icon="el-icon-edit" @click="save">保存</el-button>

        </td>
        <td v-show="is_edit">
            <el-button type="primary" icon="el-icon-delete">删除</el-button>
        </td>
    </tr>
</template>

<script>

import axios from 'axios'
export default {
    props:["classRoom"],
    data(){
        return{
            is_edit:false
        }

    },
    methods:{
        modify(){
            this.is_edit=true;
        },
        save(){
            axios({
                url: "http://localhost:8080/updateClass",
                method: "Post",
                data:this.classRoom
            })
            this.is_edit=false;
        },
        deleteClass(){
            axios({
                url: "http://localhost:8080/deleteClass",
                method: "Post",
                data:this.classRoom
            })
            // 页面刷新
            location.reload();
        },
        getStatus(){
            axios({
                url: "http://localhost:8080/getStatus",
                method: "Post",
                data:this.classRoom
            })
}
    }

}
</script>

<style scoped>

</style>